﻿using System.Collections.ObjectModel;
using System.Linq;
using System.Windows;
using WP8DataModel.Model;
using WP8DataModel.ViewModel;

namespace CeskyRozhlasWP8.ViewModel
{
    public class BackgroundRecordingPlanViewModel : BaseViewModel
    {

        private ObservableCollection<BackgroundScheduledTransferItem> _backgroundRecordingPlan;
        public ObservableCollection<BackgroundScheduledTransferItem> BackgroundRecordingPlan
        {
            get { return _backgroundRecordingPlan; }
            set { SetField(ref _backgroundRecordingPlan, value); }
        }

        private Visibility _selectionVisibility = Visibility.Collapsed;
        public Visibility SelectionVisibility
        {
            get { return _selectionVisibility; }
            set { SetField(ref _selectionVisibility, value); }
        }

        public async void DeleteAllCompleted(object sender, System.EventArgs e)
        {
            BackgroundScheduleModel.Instance.Delete(BackgroundRecordingPlan.Where(item => item.MovedToMediaLibrary));
            BackgroundRecordingPlan = await BackgroundScheduleModel.Instance.GetTransfersStatus(); 
        }
    }
}